package javaStu.jdk8;

import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: leiwenkang
 * @date: 2020/5/20
 * @time: 11:24
 */
public class ListTest {
    public static void main(String[] args) {
        List<Stu> list = Lists.newArrayList();
        list.add(new Stu(1, "leiwenkang1", 1));
        list.add(new Stu(2, "leiwenkang2", 1));
        list.add(new Stu(3, "leiwenkang3", 1));
        list.add(new Stu(4, "fanxiaoyuan1", 0));
        list.add(new Stu(5, "fanxiaoyuan2", 0));
        list.add(new Stu(6, "fanxiaoyuan3", 0));


        List<Stu> list2 = list.stream().filter(stu -> new Integer(1).equals(stu.sex)).collect(Collectors.toList());

        List<Stu> list3 = list2.stream().filter(stu -> stu.name.equals("leiwenkang2")).collect(Collectors.toList());

        System.out.println(list);
        System.out.println(list2);
        System.out.println(list3);
    }
}

@Data
@AllArgsConstructor
class Stu {
    int id;
    String name;
    int sex;
}
